package com.flash.BusinessParameters.controller;

import com.flash.BusinessParameters.entity.Broker;
import com.flash.BusinessParameters.entity.BrokerDealSeat;
import com.flash.BusinessParameters.entity.DealSeat;
import com.flash.BusinessParameters.entity.ExchangeRate;
import com.flash.BusinessParameters.service.DealSeatService;
import com.flash.GlobalManagement.util.Dbutil;
import com.flash.GlobalManagement.util.TableIdUtil;
import com.flash.GlobalManagement.util.TableNameUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class DealSeatController {

    @Resource
    DealSeatService dealSeatService;
    @Resource
    Dbutil dbutil;


    @RequestMapping("/selectDealSeatMap")
    //查询全部
    public Map selectDealSeat(String seatName,int page, int limit){
        HashMap map = new HashMap();
        List<BrokerDealSeat> dealSeatList = dealSeatService.selectDealSeatMap(seatName,page,limit);
        int i = dealSeatService.selectCountDealSeat();
        System.out.println(dealSeatList);
        System.out.println("进来");
        map.put("code",0);
        map.put("msg","");
        map.put("data",dealSeatList);
        map.put("count",i);
        return map;
    }


    @RequestMapping("/selectDealSeat")
    //查询全部
    public Map selectDealSeat(){
        System.out.println("查询全部");
        HashMap map=new HashMap();
        List<DealSeat> dealSeatList = dealSeatService.selectDealSeat();
        int i = dealSeatService.selectCountDealSeat();
        System.out.println(dealSeatList);
        map.put("code",0);
        map.put("msg","");
        map.put("data",dealSeatList);
        map.put("count",1);
        return map;
    }

    @RequestMapping("/insertDealSeatDealSeat")
    //增加
    public String insertDealSeatDealSeat(DealSeat dealSeat){
        System.out.println("添加用户");
        dealSeat.setSeatId(dbutil.getMaxId2(TableIdUtil.SID, TableNameUtil.S));
        int i = dealSeatService.insertDealSeat(dealSeat);
        System.out.println(i+"aaa");
        if (i>0){
            return "ok";
        }else{
            return "no";
        }
    }

    @RequestMapping("/updateDealSeats")
    //修改
    public int updateDealSeat(DealSeat dealSeat){
        System.out.println(dealSeat);
        System.out.println("这是修改");
        int i = dealSeatService.updateDealSeat(dealSeat);
        System.out.println(i);
        return i;
    }

    @RequestMapping("/deleteDealSeats")
    //删除
    public int deleteDealSeats(String seatId){
        System.out.println("删除");
        int i = dealSeatService.deleteDealSeat(seatId);
        System.out.println(i);
        return i;
    }
}
